
export const state = () => ({
  user: null,
  uid: null,
  cookie: null,
})

export const mutations = {
  // 保存登录用户信息
  SAVEUSERINFO(state, obj) {
    state.user = obj
    state.uid = obj.profile.userId
    state.cookie = obj.cookie
    localStorage.setItem('user', JSON.stringify(obj))
  },
}

export const getters = {
  // 获取用户信息
  GETUSER(state) {
    return state.user
  },
  // 获取uid
  GETUID(state) {
    if(state.user){
      return state.user.profile.userId
    }
    return null
  },
  // 获取cookie
  GETCOOKIE(state) {
    if(state.user){
      return state.user.cookie
    }
    return null
  },
}
